﻿using LocalNas.Application.Service.Wallhaven.Dto;
using System.IO;

namespace LocalNas.Application.Service;

[ApiDescriptionSettings(ConstSwaggerGroup.NAS平台, Name = "壁纸服务", Order = 100)]
public class SysSettingService : IDynamicApiController, ITransient
{
    private readonly SqlSugarRepository<SysSetting> _sysSettingRep;
    public SysSettingService(SqlSugarRepository<SysSetting> sysSettingRep)
    {
        _sysSettingRep = sysSettingRep;
    }
    /// <summary>
    /// 所有设置
    /// </summary> 
    /// <returns></returns>
    [HttpGet("/SysSetting/AllSetting")]
    public async Task<List<SysSetting>> AllSetting()
    { 
        return await _sysSettingRep.AsQueryable().ToListAsync();
    }

    [HttpPost("/SysSetting/SaveSetting")]
    public async Task SaveSetting(SysSetting dto)
    {
        await _sysSettingRep.AsUpdateable()
           .SetColumns(u => u.Value == dto.Value)
           .SetColumns(u => u.Remark == dto.Remark)
           .Where(x => x.Id == dto.Id)
           .ExecuteCommandAsync();
    }
}
